package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.Map;

public class Main2Activity extends AppCompatActivity implements View.OnClickListener {

    private EditText et_account;
    private EditText et_password;
    private Button btn_login;

    private EditText editText1;
    private EditText editText2;
    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);
        initView();
        Map<String, String> userInfo = FileSaveQQ.getUserInfo(this);
        if(userInfo != null){
            et_account.setText(userInfo.get("account"));
            et_password.setText(userInfo.get(et_password));

        }
        initData();
        initEvent();
    }



    private void initView() {
        editText1 = findViewById(R.id.et_account);
        editText2 = findViewById(R.id.et_password);
        button = findViewById(R.id.btn_login);
        btn_login.setOnClickListener(this);

    }

    private void initData() {

    }
    private void initEvent() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_login:
            String account = et_account.toString().trim();
            String password = et_password.toString();
            if(TextUtils.isEmpty(account)){
                Toast.makeText(this, "请输入qq账号", Toast.LENGTH_SHORT).show();
                return;
            }
            if(TextUtils.isEmpty(password)){
                Toast.makeText(this, "请输入qq密码", Toast.LENGTH_SHORT).show();
                return;
            }
                Toast.makeText(this, "登陆成功", Toast.LENGTH_SHORT).show();
            boolean isSaveSucces = FileSaveQQ.saveUserInfo(this, account, password);
            if(isSaveSucces){
                Toast.makeText(this, "保存成功", Toast.LENGTH_SHORT).show();
            }else {
                Toast.makeText(this, "保存失败", Toast.LENGTH_SHORT).show();
            }
        }

    }
}
